package ruifeng.zcj.communcationring.ui;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ImageView;

import com.google.zxing.WriterException;

import java.io.IOException;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.bingoogolapple.qrcode.core.BGAQRCodeUtil;
import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder;
import ruifeng.zcj.communcationring.R;
import ruifeng.zcj.communcationring.groble.utils.FileUtil;
import ruifeng.zcj.communcationring.groble.utils.QrCodeUtils;

/****
 * 生成带logo的二维码
 * **/
public class AtestActivity extends Activity {

    @Bind(R.id.imageView2)
    ImageView mImageView2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.atest);
        ButterKnife.bind(this);
        try {
            qcCode();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void qcCode() throws IOException {
        Bitmap logoBitmap =  BitmapFactory.decodeResource(AtestActivity.this.getResources(), R.mipmap.icon2);
//        saveFile
        Bitmap simp =  QRCodeEncoder.syncEncodeQRCode("http://m.tongxinquanzi.com/index.php/index/Index/appdown.html", BGAQRCodeUtil.dp2px(AtestActivity.this, 200), Color.BLACK, Color.WHITE, logoBitmap);
        FileUtil.saveFile(simp,"test");
        mImageView2.setImageBitmap(simp);

    }
}
